  import {
    token_expires
  } from '@/utils/Keyword'
  import {commitOrder} from "@/api/commitOrder"
  const comitorder = {
    state: {
      items: []
    },
    mutations: {
      COMMIT_ORDER: (state, data) => {
          state.items = data;
          var cate=data.shops[0].goodses[0].skuName.split(" ");
          state.items.cate=cate;
      }
    },
    actions: {
      ORDERCOMMIT({
        commit,
        state
      }, info) {
        return new Promise((resolve, reject) => {
            commitOrder(info).then(res => {
            if (res != token_expires) {
              commit("COMMIT_ORDER", res);
              resolve(res)
            } else if(res == token_expires){
              resolve(token_expires)
            }else{
              resolve(false)
            }
          }).catch(err => {
            resolve(false)
          })
        })
      }
    }
  }
  export default comitorder
  